package top.chatgqt.SmartChargeStation.mqtt.client.service;

import org.springframework.integration.annotation.IntegrationComponentScan;
import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.mqtt.support.MqttHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.annotation.Header;
import top.chatgqt.SmartChargeStation.mqtt.client.model.MqttConstants;
import top.chatgqt.SmartChargeStation.protocol.mqtt.message.ChargePayload;

/*
    网关
    @MessagingGateway的作用：
        拦截发送的mqtt消息，然后投放到消息通道

        defaultRequestChannel: 指定投放到哪个通道


     @IntegrationComponentScan的作用：
        让spring boot可以扫描到@MessagingGateway
 */
@IntegrationComponentScan
@MessagingGateway(defaultRequestChannel = MqttConstants.OUT_CHANNEL)
public interface MqttService {

    // 发送消息
    void send(@Header(MqttHeaders.TOPIC) String topic, ChargePayload message);

    void send(@Header(MqttHeaders.TOPIC) String topic, Message<byte[]> message);
}
